package org.example.test1;

public class 提取括号 {
    public static void main(String[] args) {
        String reportFormName = "细胞因子12项检测[腹透液,PET时留取]";
        String info=extractContentInBrackets(reportFormName);
        System.out.printf("info",info);
    }

    private static String extractContentInBrackets(String reportFormName) {
        int startIndex = reportFormName.indexOf('[');
        int endIndex = reportFormName.indexOf(']');
        if (startIndex != -1 && endIndex != -1 && endIndex > startIndex) {
            // 提取方括号内的内容
            String contentInBrackets = reportFormName.substring(startIndex + 1, endIndex);
            // 分割内容
            String[] contents = contentInBrackets.split(",");
            // 检查是否包含 "腹透液"
            for (String content : contents) {
                if (content.trim().equals("腹透液")) {
                    return "腹透液";
                }
            }
        }
        return "";
    }
}